import { createSlice } from "@reduxjs/toolkit"

const initialState = {
    userInfo: {},
}

export const homeSlice = createSlice({
    name: "home",
    initialState,
    reducers: {
        save_user_info: (state, action) => {
            // action参数是一个对象，{type:save_user_info,payload:{name:test}},
            // payload属性就是在index.js中的save_user_info(test_user)调用方法中的实参
            state.userInfo = action.payload
        },
    },
})

export const { save_user_info } = homeSlice.actions

export default homeSlice.reducer
